package com.crm.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.crm.domain.dto.QueryPost;
import com.crm.domain.entity.Post;
import com.crm.mapper.PostMapper;
import com.crm.service.PostService;
import com.github.pagehelper.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;


@Service
@RequiredArgsConstructor
public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements PostService {

/*    *
     * 分页查询所有岗位
     *
     * @param queryPost
     * @return*/

    @Override
    public Page<Post> queryAll(QueryPost queryPost) {
        //1.构建分页对象

        //2.调用Mapper查询数据
        //2.1构建查询条件
        LambdaQueryWrapper<Post> wrapper = Wrappers.<Post>lambdaQuery()
                .eq(ObjectUtil.isNotEmpty(queryPost.getPostName()), Post::getPostName, queryPost.getPostName())
                .eq(ObjectUtil.isNotEmpty(queryPost.getPostCode()), Post::getPostCode, queryPost.getPostCode())
                .eq(ObjectUtil.isNotEmpty(queryPost.getStatus()), Post::getStatus, queryPost.getStatus());

        //2.2用m-plus查询
        return null;
    }
}
